package com.vhall.component.service.room.event.handler.inav;

import com.vhall.component.service.room.event.handler.AbstractEventHandler;
import com.vhall.component.service.room.event.handler.EventHandlerType;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

import static com.vhall.component.service.room.event.EventConstant.USE_RENTER_ROOM;

/**
 * 互动房间有人加入
 *
 * @author jingwen.li
 * @date 2023/2/16
 */
@Slf4j
@Component
@EventHandlerType(USE_RENTER_ROOM)
public class UserEnterRoomEventHandler extends AbstractEventHandler {
    @Override
    public void handle(Map<String, Object> callBack) {
        log.info("收到互动房间有人加入事件：{}, 事件详情：{}", USE_RENTER_ROOM, callBack);
        //        room_id	string	互动房间号
        //        unique_id	string	互动成员会话唯一ID
        //        user_id	string	互动成员用户ID
        //        event_ts	long	Unix 时间戳，事件产生时间戳
        //        time	long	Unix 时间戳，底层事件上报时间戳
        //        event	string	事件类型名称，为“UserEnterRoom”
        //        app_id	string	应用ID
        long ts = (long) callBack.get("event_ts");
        Date date = new Date();
        date.setTime(ts);
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        log.info("互动房间：{}, user[unique_id={}]:{},在[{}]进入房间", callBack.get("room_id"), callBack.get("unique_id"), callBack.get("user_id"), sf.format(date));
    }
}
